home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / logbatch / setdrv.arc / SETDRIVE.PAS < prev   
Pascal/Delphi Source File  |  1988-06-28  |  3KB  |  97 lines

  1. Program SetDrive; { Author: David Bennett / Date 6/28/88 / Version 1.0 }
  2.  
  3. { This sets the current Novell Drive on the system
  4.  
  5.   EX.
  6.  
  7.   SETDRIVE 2 - Will set the current drive to the second Novell assigned
  8.                drive on the system.
  9. }
  10.  
  11. Uses
  12.   Crt, Dos;
  13.  
  14. { * This routine prints an error message and aborts the program
  15. { *
  16. }
  17. Procedure Err(ErrSt : String);
  18. Begin
  19.   WriteLn('Error - ', ErrSt);
  20.   Halt(1);
  21. End;
  22.  
  23. { * This procedure explains the program to the screen
  24. { *
  25. }
  26. Procedure Explain;
  27. Begin
  28.   ClrScr;
  29.   WriteLn;
  30.   WriteLn('Program: SETDRIVE / Author: Dave Bennett / Date: 6-28-88 / Version: 1.0');
  31.   WriteLn;
  32.   WriteLn('Description:');
  33.   WriteLn;
  34.   WriteLn('  This program sets the default drive to the sequential Novell drive specified.');
  35.   WriteLn('  This program and it''s source code have been relased to the public domain');
  36.   WriteLn('  by the author. DHB.');
  37.   WriteLn;
  38.   WriteLn('Example:');
  39.   WriteLn;
  40.   WriteLn('  SETDRIVE 2 - Will log to the systems second Novell drive.');
  41.   WriteLn;
  42. End;
  43.  
  44. { * This Novell function returns the number of local disk drives
  45. { *
  46. }
  47. Function LocalDrives : Byte;
  48. Var
  49.   Regs : Registers;
  50. Begin
  51.   With Regs Do Begin
  52.     AH := $DB;
  53.     MsDos(Regs);
  54.     LocalDrives := AL;
  55.   End;
  56. End;
  57.  
  58. { * This MSDOS function selects the default drive (A = 0, B = 1,...)
  59. { *
  60. }
  61. Procedure SelectDrive(Drive : Byte);
  62. Var
  63.   Regs : Registers;
  64. Begin
  65.   With Regs Do Begin
  66.     AH := $0E;
  67.     DL := Drive;
  68.     MsDos(Regs);
  69.   End;
  70. End;
  71.  
  72. Var
  73.  Drive : Byte;
  74.  P     : Integer;
  75.  
  76. { *** MAIN PROGRAM *** }
  77.  
  78. Begin
  79.   If ParamCount < 1 Then Begin           { If no command line params then  }
  80.     Explain;                             {   Explain the program           }
  81.     Write('Drive Number To Select : ');  {   Get the drive number from     }
  82.     {$I-} ReadLn(Drive); {$I+}           {     the user.                   }
  83.     If (IOResult <> 0) Then              {   If invalid drive number then  }
  84.       Err('Invalid drive specified!');   {     Show an error and halt      }
  85.   End Else Begin                         { If parameter found then         }
  86.     Val(ParamStr(1), Drive, P);          {   Make parameter a value        }
  87.     If P > 0 Then                        {   If invalid value string then  }
  88.       Err('Invalid drive specified!');   {     Show error and halt         }
  89.   End;                                   {                                 }
  90.   If Drive < 1 Then                      {  Make sure drive is 1 or >      }
  91.     Err('Invalid drive specified!');     {                                 }
  92.   Drive := Drive - 1;                    {  Subtract 1 for MSDOS 0Eh func. }
  93.   Drive := Drive + LocalDrives;          {  Add number of local drives     }
  94.   SelectDrive(Drive);                    {  Goto the drive                 }
  95. End. {SetDrive}
  96.  
  97.